/**
 * @file RssReader.h
 *
 * Klasa czytnika RSS - nagłówek.
 *
 * @author Zbigniew Siciarz
 * @date 2009
 * @version 2.0.0
 * @since 2.0.0
 */

#ifndef RSSREADER_H_
#define RSSREADER_H_

#include <QDomElement>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QObject>
#include <QString>
#include <QUrl>

/**
 * Prosty czytnik RSS.
 */
class RssReader : public QObject
{
    Q_OBJECT

public:
    RssReader(QObject* parent = 0);
    virtual ~RssReader();

    void setNetworkManager(QNetworkAccessManager* mgr) { m_mgr = mgr; }
    void setTemplate(const QString& tpl) { m_template = tpl; }

    void downloadFeed(const QUrl& url);
    QString getParsedFeed() const;

signals:
    void parsingFinished();

private:
    QNetworkAccessManager* m_mgr;
    QString formattedFeed;
    QString m_template;

    void parseReply(QNetworkReply* reply);
    void parseItem(const QDomElement& element);

private slots:
    void readFinished();
};

#endif /* RSSREADER_H_ */
